
var map,
	district,
	polygons = [],
	citycode,
	pointRes = [
		// 	{
		// 	ids: 0,
		// 	"lat": "117.910629",
		// 	"_long": "33.482982",
		// 	"Address": "泗县政府",
		// 	"Name": "泗县新时代文明实践中心",
		// 	"LXR": "姜丽亚",
		// 	"Phone": "13813532332",
		// 	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
		// 	"Grade": "markCenter",
		// 	"id": 895,
		// 	"ActyXY": "28.683782$115.860565",
		// 	"brief": "<div class=huodongs><div><span>"+briefs+"</span></div></div>"
		// }
	],
	zoom = 10,
	mapCenter = [117.910629,33.500991], //地图中心坐标
	orgStatistics = {}, //定义全局变量，统计量


	BASEURL = 'http://cms.sixian.cst-info.cn:9001/api/v2/';
$.when(
	$.getJSON(BASEURL + 'Statistics/areaPMList?level=3'), //第三方数据，站点信息

	$.getJSON(BASEURL + 'Statistics/areaPMList?level=4&pagesize=99'), //第三方数据，站点信息

	$.getJSON(BASEURL + 'Statistics/areaPMList?level=5&pagesize=999'), //第三方数据，站点信息


).done(function (rescenter, res,zdres) {
	rescenter[0].data.forEach(function (v, i) {
		if (v.lat != "") {
			pointRes.push({
				"_long": v.lat,
				"lat": v._long,
				ids: (i),
				"Address": v.Address,
				"Grade": "markCenter",
				"LXR": v.LXR,
				"Name": v.Name,
				"activity_num": v.activity_num,
				"article_num": v.article_num,
				"brief": v.content =="" ? "暂无简介":v.content,
				"content": v.content,
				"id": v.id,
				"job_time": v.job_time,
				"rank": v.rank,
				"shijiansuo_num": v.shijiansuo_num,
				"volunteer_group_num": v.volunteer_group_num,
				"volunteer_num": v.volunteer_num,
			})
		}
	})

	res[0].data.forEach(function (v, i) {
		if (v.lat != "") {
			pointRes.push({
				"_long": v.lat,
				"lat": v._long,
				ids: (i + 1),
				"Address": v.Address,
				"Grade": "markSZ",
				"LXR": v.master,
				"Name": v.Name,
				"activity_num": v.activity_num,
				"article_num": v.article_num,
				"brief": v.content =="" ? "暂无简介":v.content,
				"content": v.content,
				"id": v.id,
				"job_time": v.job_time,
				"rank": v.rank,
				"shijiansuo_num": v.shijiansuo_num,
				"volunteer_group_num": v.volunteer_group_num,
				"volunteer_num": v.volunteer_num,
			})
		}
	})

	zdres[0].data.forEach(function (v, i) {
		if (v.lat != "") {
			pointRes.push({
				"_long": v.lat,
				"lat": v._long,
				ids: (res[0].data.length +i+1),
				"Address": v.Address,
				"Grade": "markZD",
				"LXR": v.master,
				"Name": v.Name,
				"activity_num": v.activity_num,
				"article_num": v.article_num,
				"brief": v.content =="" ? "暂无简介":v.content,
				"content": v.content,
				"id": v.id,
				"job_time": v.job_time,
				"rank": v.rank,
				"shijiansuo_num": v.shijiansuo_num,
				"volunteer_group_num": v.volunteer_group_num,
				"volunteer_num": v.volunteer_num,
			})
		}
	})

	console.log(pointRes)
	getPointZD();

	// console.log(pointRes, "999999999999999999999999999999")
})
pointRess = [{
	"lat": "115.02268",
	"_long": "25.861908",
	"Address": "赣县区政府",
	"Name": "赣县区新时代文明实践中心",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markCenter",
	"ActyXY": "28.683782$115.860565"
}, {
	"lat": "115.150672",
	"_long": "25.862193",
	"Address": "大田乡",
	"Name": "大田乡新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.20011",
	"_long": "25.801625",
	"Address": "长洛乡政府",
	"Name": "长洛乡新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.005103",
	"_long": "25.613547",
	"Address": "王母渡镇政府",
	"Name": "王母渡镇新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.078831",
	"_long": "25.689757",
	"Address": "大埠乡政府",
	"Name": "大埠乡新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.109044",
	"_long": "25.486933",
	"Address": "韩坊镇",
	"Name": "韩坊镇新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.058575",
	"_long": "25.902267",
	"Address": "茅店镇",
	"Name": "茅店镇新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.138913",
	"_long": "25.952596",
	"Address": "江口镇",
	"Name": "江口镇新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.120373",
	"_long": "26.032522",
	"Address": "石芜乡",
	"Name": "石芜乡新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "115.301648",
	"_long": "26.092971",
	"Address": "三溪乡",
	"Name": "三溪乡新时代文明实践所",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markSZ",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "114.81207",
	"_long": "26.093587",
	"Address": "沙地镇",
	"Name": "沙地镇新时代文明实践站",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markZD",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "114.967251",
	"_long": "26.101604",
	"Address": "湖江镇",
	"Name": "泾口乡新时代文明实践站",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markZD",
	"ActyXY": "28.716005$115.727013"
}, {
	"lat": "114.884854",
	"_long": "25.989325",
	"Address": "五云镇",
	"Name": "五云镇新时代文明实践站",
	"LXR": "姜丽亚",
	"Phone": "13813532332",
	"RowGuid": "cd20f0b6-fd84-4855-a969-d836c8ed6868",
	"Grade": "markZD",
	"ActyXY": "28.716005$115.727013"
},];

var cmsRes = [{
	bizType: "common",
	categoryId: "2923",
	name: "赣县区新时代文明实践中心",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2924",
	name: "大田乡新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2925",
	name: "长洛乡新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2926",
	name: "王母渡镇新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2928",
	name: "大埠乡新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2931",
	name: "韩坊镇新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2931",
	name: "茅店镇新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2931",
	name: "江口镇新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2932",
	name: "石芜乡新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2934",
	name: "三溪乡新时代文明实践所",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2927",
	name: "沙地镇新时代文明实践站",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2930",
	name: "泾口乡新时代文明实践站",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
}, {
	bizType: "common",
	categoryId: "2930",
	name: "五云镇新时代文明实践站",
	picUrl: "",
	purposeType: "category",
	vpgType: "",
},];

map = new AMap.Map("mapBox", {
	resizeEnable: true,
	mapStyle: "amap://styles/darkblue",
	center: mapCenter,
	zoom: zoom
});

//行政区划查询
var opts = {
	subdistrict: 1, //返回下一级行政区
	showbiz: false //最后一级返回街道信息
};

district = new AMap.DistrictSearch(opts); //注意：需要使用插件同步下发功能才能这样直接使用

district.search("泗县", function (status, result) {
	if (status == "complete") {
		// console.log(result)
		getData(result.districtList[0]);
	}
});

//获取地图数据，绘制区域图层
function getData(data, level) {
	var bounds = data.boundaries;
	if (bounds) {
		for (var i = 0, l = bounds.length; i < l; i++) {
			var polygon = new AMap.Polygon({
				map: map,
				strokeWeight: 1,
				strokeColor: "#0091ea",
				fillColor: "#80d8ff",
				fillOpacity: 0.2,
				path: bounds[i]
			});
			polygons.push(polygon);
		}
		// map.setFitView(8); //地图自适应
	}
}

function loadMap(obj) {
	//清除地图上所有覆盖物
	for (var i = 0, l = polygons.length; i < l; i++) {
		polygons[i].setMap(null);
	}
	var keyword = "泗县"; //关键字
	var adcode = "341324"; //行政区代码
	var value = "district";
	district.setLevel(value); //行政区级别
	district.setExtensions("all");
	//行政区查询
	//按照adcode进行查询可以保证数据返回的唯一性
	district.search(adcode, function (status, result) {
		// console.log(status, result)
		if (status === "complete") {
			getData(result.districtList[0], "district");
		}
	});

	//地图加载完成
	map.on("complete", function () {

	})
}

/*
 * 获取实践中心、所、站 
 */
var allPoint; //所有站点数据
var allPointCmsRes; //实践所的cms数据
function getPointZD() {
	allPoint = pointRes;
	allPointCmsRes = cmsRes;

	//数据匹配
	allPoint.forEach(function (v, i) {
		allPointCmsRes.forEach(function (item, index) {
			if (v.Name == item.name) {
				v.categoryId = item.categoryId;
			}
		})
	});


	setPlaceMarker();
	// flickerStation();
}

/*
 * 设置实践所Marker
 */
var placeMarker = null; //实践所Marker
var placeMarkerList = []; //所有实践所的marker数据
var placeMarkerArr = []; //所有实践所的marker数组,用于地图层级隐藏
function setPlaceMarker() {
	var _this = this;
	placeMarkerList = allPoint.slice(0, 999); //前12条为实践中心和实践所
	placeMarkerList.forEach(function (v, i) {
		var mapContent = '';
		console.log(v.Grade)
		var zIndex=0
		if (v.Grade == "markCenter") { //实践中心
			mapContent = '<div class="pentagram" style="z-index:99"></div>'
			zIndex=150
		} else if(v.Grade == "markSZ"){ //实践所
			mapContent = '<div class="noCirle" style="background:#cde87d;z-index:98; data-id=' + v.ids + '"></div>'
			zIndex=140
		}else{
			mapContent = '<div class="noCirle noCirles" style="background:#008abb;z-index:10; data-id=' + v.ids + '"></div>'
			zIndex=130
		}
		placeMarker = new AMap.Marker({
			map: map,
			content: mapContent,
			position: [v.lat, v._long],
			title: v.Name,
			offset: new AMap.Pixel(0, 0),
			zIndex
		});
		placeMarker.on("click", function (e) {
			mapCenter = map.getCenter(); //获取当前地图级别
			indexData.GetStationInfo(v.id,function (res) {
					openInfo(v.ids, v.Name, v.Grade, e.target.getPosition(), res);
			})
		});
		placeMarkerArr.push(placeMarker);
	})
	$('.loader').hide(); //隐藏loading
}

/*
 * 设置实践站Marker
 */
var stationMarker = null; //实践站Marker
var stationMarkerList = []; //实践站Marker数据
var stationMarkerArr = []; //实践站Marker数组,用于地图层级隐藏
function setStationMarker() {
	stationMarkerList = allPoint.slice(9, allPoint.length); //实践站
	stationMarkerList.forEach(function (v, i) {
		if (v.Grade == "markZD") { //实践站
			var stationContent = '<div class="noCirle" style="background:#12fe85;"></div>';
			stationMarker = new AMap.Marker({
				map: map,
				content: stationContent,
				position: [v.lat, v._long],
				title: v.Name,
				offset: new AMap.Pixel(0, 0)
			});

			stationMarker.on("click", function (e) {

				mapCenter = map.getCenter(); //获取当前地图级别
				openInfo(v.categoryId, v.Name, v.Grade, e.target.getPosition());
			});

			stationMarkerArr.push(stationMarker);
		}
	})
}

/*
 * 云图 “中心、所、站” 弹出层打开样式
 */
var infoWindow = null; //信息窗体
function openInfo(categoryId, name, type, position, placeData) {
	var infoHTML = '';
	//	if(type == "markCenter") { //实践中心
	if (type == "markCenter") { //实践中心
		//	} else if(type == "markSZ") { //实践所
		console.log(pointRes)
		infoHTML = `<div class="amap-ui-smp-ifwn-content-body">
			<h3>${name}</h3>
			<div class="closeWindow placeClose" onclick="closeTips()"></div>
			<div class="showTips-content">
				<div class="place-content">
					<span>下属实践所:<em>${$(".place").html()}</em></span>
					<span>下属实践站:<em>${$(".station").html()}</em></span>
					<span>下属实践点:<em>${$(".site").html()}</em></span>
					<span>志愿者团队数:<em>${$(".volunteerTeam").html()}</em></span>
					<span>志愿者总数:<em>${$(".volunteer").html()}</em></span>
					<span>活动总数:<em>${pointRes[categoryId].activity_num}</em></span>

				</div>
			</div>
			<div class="chartShow" id="chartShow"></div>
			<div class="btnContent threeBtnContent">
				<button class="amap-ui-infowindow-close openPlay" onclick="indexData.getActivityList(${categoryId},'基本简介')">基本简介</button>
				<button class="amap-ui-infowindow-close openPlay"  onclick="indexData.getActivityTeamsList(${categoryId},'志愿团队')">志愿团队</button>
				
				<button class="amap-ui-infowindow-close openPlay liveBtn" onclick="indexData.getActivityTeamsList(${categoryId},'实践活动')">实践活动</button>
			</div>
		</div>`;


	} else if ( type == "markSZ"||type == "markZD") { //实践所





		infoHTML = `<div class="amap-ui-smp-ifwn-container">
			<div class="amap-center">
				<h2>${name}</h2>
				<div class="closeWindow" onclick="closeTips()"></div>
				<div class="showTips-content1">
					<span>联系人:<i>${pointRes[categoryId].LXR}</i></span>
					<span>所站地址:<i>${pointRes[categoryId].Address}</i></span>
					<span>所站联系电话:<i>0797-4445091</i></span>
				</div>
				<div class="btnContent twoBtnContent">
					<button class="amap-ui-infowindow-close openPlay" onclick="indexData.getActivityList(${categoryId},'基本简介')">基本简介</button>
				</div>
			</div>
		</div>`;


	} else if (type == "markZD") { //实践站
		infoHTML = `<div class="amap-ui-smp-ifwn-container">
			<div class="amap-center stationBg">
				<h2>${name}</h2>
				<div class="closeWindow" onclick="closeTips()"></div>
				<div class="btnContent twoBtnContent">
					<button class="amap-ui-infowindow-close openPlay" onclick="indexData.getActivityList(${categoryId},'基本简介')">基本简介</button>
					<button class="amap-ui-infowindow-close openPlay" onclick="indexData.getActivityList(${categoryId},'基本简介',1)">组织架构</button>
					<button class="amap-ui-infowindow-close openPlay" onclick="push()">视频连线</button>
					<button class="amap-ui-infowindow-close openPlay liveBtn" onclick="push()">视频连线</button>
				</div>
			</div>
		</div>`;
	}

	infoWindow = new AMap.InfoWindow({
		isCustom: true,
		autoMove: true,
		anchor: 'bottom-center',
		content: infoHTML, //使用默认信息窗体框样式，显示信息内容
		offset: new AMap.Pixel(0, 0)
	});

	infoWindow.open(map, position);
	if (infoWindow.getIsOpen()) {
		if (type == "markCenter") {
			//		if(type == "markSZ") {

			setTimeout(function () { //加个延迟，防止信息窗体加载后获取不到echart元素
				showActiveChart(placeData.items);
			}, 100)
		} else {
			setTimeout(function () { //加个延迟，防止信息窗体加载后获取不到echart元素
				showActiveChart(placeData.items);
			}, 100)
		}
	}
}

var flickerMarker = null; //闪烁Marker
var flickerMarkerAllList = []; //所有筛选出来的活动闪烁Marker数据
var flickerMarkerList = []; //闪烁Marker数据
var flickerMarkerListArr = []; //筛选出来的数据
var flickerMarkerArr = []; //闪烁Marker数组,用于地图层级隐藏
//获取筛选正在进行中的活动，归属实践站闪烁
function flickerStation() {
	var step = 7; //获取当前时间前7天 & 后7天；获取两周中的活动数
	var currentTime = new Date();
	var startTime = new Date(currentTime.getTime() - step * 24 * 60 * 60 * 1000);
	var endTime = new Date(currentTime.getTime() + step * 24 * 60 * 60 * 1000);
	var today = getNowFormatDate(currentTime);
	var StartDay = getNowFormatDate(startTime);
	var EndDay = getNowFormatDate(endTime);

	$.getJSON(BASEURL + 'getDayEnlistList', {
		PageIndex: 1,
		PageSize: 500,
		StartDay: StartDay,
		EndDay: EndDay,
		IsFilterPoint: 1 //是否筛选阵地
	}, function (res) {
		// console.log(res);
		res = res.data;
		//		flickerMarkerAllList = res;
		flickerMarkerAllList = [{
			"name": "深化文明城市建设，实施路长单位的长效管理",
			"ID": "e373ddcf-7194-4666-85ab-2aa634b8dfc2",
			"time": "2019-08-26 14:30:00",
			"address": "溧城镇花园路",
			"from": "溧阳市信访局志愿者服务队",
			"teamGuid": "6c8c4da0-89b3-4ed7-868a-41cf0a4e4a4c",
			"explanation": null,
			"TeamName": null,
			"claim": null,
			"bmqk": null,
			"bmrs": "0",
			"zmdx": null,
			"hdewm": null,
			"startTime": "2019-08-26 14:30:00",
			"endTime": "2019-08-26 17:30:00",
			"img": [],
			"PointName": ""
		},];

		var nowTime = currentTime.getTime();
		flickerMarkerAllList.forEach(function (v, i) {
			//先根据时间筛选正在进行中的活动
			var sTime = new Date(v.startTime.replace(/-/g, "/"));
			var eTime = new Date(v.endTime.replace(/-/g, "/"));
			if (nowTime > sTime && nowTime < eTime) {
				flickerMarkerListArr.push(v)
			}
		})
		//再匹配站点信息获取坐标渲染
		if (flickerMarkerListArr.length != 0) {
			flickerMarkerListArr.forEach(function (v, i) {
				allPoint.forEach(function (item, index) {
					if (v.PointName == item.Name) {
						flickerMarker = new AMap.Marker({
							map: map,
							content: '<div class="water"><div class="circle" id="circle" style="background:#12fe85;"><div class="circle1" id="circle1" style="border: 1px solid #12fe85;"></div><div class="circle2" id="circle2" style="border: 1px solid #12fe85;"></div></div>',
							position: [item.lat, item._long],
							title: item.Name,
							offset: new AMap.Pixel(0, 0),
							zIndex: 160
						});

						flickerMarker.on("click", function (e) {
							mapCenter = map.getCenter(); //获取当前地图级别
							openInfo(item.categoryId, item.Name, item.Grade, e.target.getPosition());
						});

						flickerMarkerArr.push(flickerMarker);
					}
				})
			})
		}

		//更新
		var updataTimer = null;
		var upDateTime = 15 * 60 * 1000;
		(function flickerStationUpdata() {
			updataTimer && clearTimeout(updataTimer);
			setTimeout(function () {
				map.remove(flickerMarkerArr);
				flickerMarkerArr = [];
				flickerMarkerAllList = [];
				flickerMarkerListArr = [];
				flickerStation();
			}, upDateTime)
		})()
	})
}

var chartTimer = null,
	myChartBar = null,
	chartCount = 0,
	chartTime = 3000;
// 实践所展示的柱状图
function showActiveChart(dataList) {
	chartCount = 0;
	myChartBar = null;

	var activeChartList = []
	var arrX = []; //x轴：村名
	var arrY1 = []; //y轴1
	var arrY2 = []; //y轴2
	var showBarLen = 4; //柱状图展示数量
	var x_data = [];
	var yData1 = [];
	var yData2 = [];

	activeChartList = dataList;
	activeChartList.forEach(function (v) {
		//正则实现每隔固定字符换行
		var str = v.title.replace(/[^\x00-\xff]/g, "$&\x01").replace(/.{16}\x01?/g, "$&\n").replace(/\x01/g, "");
		arrX.push(str);
		arrY1.push(v.activitys == '' ? 0 : v.activitys);
		arrY2.push(v.volunteers == '' ? 0 : v.volunteers);
	});

	showBarLen = activeChartList.length > showBarLen ? showBarLen : activeChartList.length;
	x_data = arrX.slice(0, showBarLen);
	yData1 = arrY1.slice(0, showBarLen);
	yData2 = arrY2.slice(0, showBarLen);

	myChartBar = echarts.init(document.getElementById("chartShow"));
	option = {
		tooltip: {
			trigger: 'axis',
			confine: true, //是否将悬浮框限制在图例中
			axisPointer: {
				type: 'shadow'
			},
			// position: function (p) {
			// 	return [p[0] - 50, p[1] - 40];
			// }
		},
		legend: {
			x: "right",
			data: ['活动次数', '团队人数'],
			textStyle: {
				color: '#FFFFFF',
				fontFamily: '微软雅黑',
				fontSize: 12,
				fontWeight: 'lighter'
			}
		},
		calculable: true,
		grid: {
			left: 0,
			right: 0,
			bottom: 0,
			top: '20%',
			padding: 0,
			containLabel: true,
			z: 22
		},
		xAxis: [{
			type: 'category',
			boundaryGap: true, //坐标轴两边留白
			data: x_data,
			axisLabel: {
				interval: 0,
				show: true,
				color: '#00F4FC',
				fontSize: 12,
			},
			axisLine: {
				lineStyle: {
					color: '#04366e'
				}
			},
			axisPointer: {
				type: 'shadow'
			},
		}],
		yAxis: [{
			type: 'value',
			axisLabel: {
				show: true,
				color: '#FE546A',
				fontSize: 12,
			},
			axisLine: {
				lineStyle: {
					color: '#04366e'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					color: "#113456",
				}
			}
		}, {
			type: 'value',
			axisLabel: {
				show: true,
				color: '#03DF98',
				fontSize: 12,
			},
			axisLine: {
				lineStyle: {
					color: '#04366e'
				}
			},
			splitLine: {
				show: false,
				lineStyle: {
					color: "#113456",
				}
			}
		}],
		series: [{
			name: '活动次数',
			type: 'bar',
			data: yData1,
			barWidth: '20px',
			itemStyle: {
				normal: {
					color: "#FE546A",
				}
			},
			label: { //图形上的文本标签
				show: true,
				position: "top",
				distance: 2,
				fontStyle: "normal",
				fontSize: 10
			}
		},
		{
			name: '团队人数',
			type: 'bar',
			data: yData2,
			barWidth: '20px',
			yAxisIndex: 1,
			itemStyle: {
				normal: {
					color: "#03DF98",
				}
			},
			label: { //图形上的文本标签
				show: true,
				position: "top",
				distance: 2,
				fontStyle: "normal",
				fontSize: 10
			}
		}
		]
	};
	myChartBar.setOption(option);

	// chartCount = arrX.length > showBarLen ? showBarLen : arrX.length;
	if (arrX.length > showBarLen) {
		chartCount = showBarLen;
	} else {
		chartCount = arrX.length;
		return;
	}
	chartTimer && clearInterval(chartTimer);
	chartTimer = setInterval(function () {
		chartCount++;
		if (chartCount >= arrX.length) {
			chartCount = 0;
		}
		x_data.shift();
		x_data.push(arrX[chartCount]);
		yData1.shift();
		yData1.push(arrY1[chartCount]);
		yData2.shift();
		yData2.push(arrY2[chartCount]);

		myChartBar.setOption(option);
	}, chartTime)

	myChartBar.on('mouseover', function (params) {
		chartTimer && clearInterval(chartTimer);
		myChartBar.dispatchAction({
			type: 'downplay',
			seriesIndex: 0,
		});
		myChartBar.dispatchAction({
			type: 'highlight',
			seriesIndex: 0,
			dataIndex: (chartCount) % showBarLen
		});
		myChartBar.dispatchAction({
			type: 'showTip',
			seriesIndex: 0,
			dataIndex: (chartCount) % showBarLen
		});
	});

	myChartBar.on('mouseout', function (params) {
		chartTimer && clearInterval(chartTimer);
		chartTimer = setInterval(function () {
			chartCount++;
			if (chartCount >= arrX.length) {
				chartCount = 0;
			}
			x_data.shift();
			x_data.push(arrX[chartCount]);
			yData1.shift();
			yData1.push(arrY1[chartCount]);
			yData2.shift();
			yData2.push(arrY2[chartCount]);

			myChartBar.setOption(option);
		}, chartTime);
	});
}

// 关闭 所、站 弹出层
function closeTips() {
	infoWindow && infoWindow.close();
	map.setZoomAndCenter(zoom, mapCenter); //设置缩放级别和中心点
}

//监听地图层级处理站点显示和隐藏
function listenZoom() {
	zoom = map.getZoom();
	// console.log("当前缩放级别：" + zoom)

	if (zoom <= 7) {
		map.remove(placeMarkerArr);
		map.remove(stationMarkerArr);
		map.remove(flickerMarkerArr);
	}
	if (zoom >= 8) {
		map.add(placeMarkerArr);
		map.add(flickerMarkerArr);
	}
	// if (zoom >= 11) {
	// 	if (stationMarkerList.length == 0) {
	// 		setStationMarker();
	// 	} else {
	// 		map.add(stationMarkerArr);
	// 	}
	// }
	if (zoom < 11) {
		map.remove(stationMarkerArr);
	}
}

map.on('zoomend', listenZoom);

var centerList, userInfo;

function getCenterCall() {
	// $.getJSON('/bigData/getActiveOrganization?type=center', function(res) {
	// 	if(res.code == 0) {
	// 		centerList = res.organizationList[0];
	// 		userInfo = centerList.userList;
	// 	}
	// })

	// centerList = {
	// 	"id": "171",
	// 	"name": "溧阳市新时代文明实践中心",
	// 	"activeActivityCount": 3,
	// 	"userList": [{
	// 		"activityId": 6378,
	// 		"id": 2767,
	// 		"imId": "",
	// 		"activityTitle": "视频连线功能-展示",
	// 		"name": "戴埠镇",
	// 		"activityStartTime": "2019-08-06 00:00:00",
	// 		"online": "0"
	// 	}, ],
	// 	"longitude": "119.484211",
	// 	"onlineCount": 1,
	// 	"latitude": "31.416911",
	// 	"code": "jurongshi",
	// 	"type": "center"
	// };
	// userInfo = centerList.userList;

}

function callOpen() {
	if (centerList.onlineCount > 0) {
		$(".personContainer").show();
	} else {
		indexData.dataTips();
	}
}

// 关闭视频通话选择弹出层
function closeCall() {
	$(".personContainer").hide();
}

//打开直播
function openLive(name) {
	var liveUrl = '';
	if (name == '南渡镇新时代文明实践所') {
		liveUrl = 'http://58.241.85.167:9191/live/jiankong-1.m3u8';
	} else if (name == '戴埠镇新时代文明实践所') {
		liveUrl = 'http://58.241.85.167:9191/live/jiankong-2.m3u8';
	} else {
		indexData.dataTips();
		return;
	}
	$('.activeLive-contanier').show();
	$('#myVideo').trigger('pause');

	chsLive.init(liveUrl);
	chsLive.videoPlay();

	$(".activeLive-contanier-quit").on("click", function () {
		$('.activeLive-contanier').hide();
		chsLive.videoPause()
	})
}

// 选中状态样式
function checkP(obj) {
	var type = $(obj)
		.find("p")
		.attr("class");
	if (type == "checkThis") {
		$(obj)
			.find("p")
			.removeClass("checkThis");
	} else {
		$(obj)
			.find("p")
			.addClass("checkThis");
	}
}

var userId = [];
var nameList = [];

function getUserId() {
	userId = [];
	$(".checkP p").each(function () {
		if ($(this).attr("class") == "checkThis") {
			userId.push($(this).attr("id"));
			nameList.push($(this).attr("name"));
		}
	});
	getUserSig(userId, nameList);
}

window.onresize = function () {
	myChartBar && myChartBar.resize();
	echartsPie.pieChart.resize();
}